﻿/* Write a program that reads a list of words, separated by spaces and prints the list in an alphabetical order. */

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace _24.ReadWordListPrintOrdered
{
    class ReadWordListPrintOrdered
    {
        static void Main()
        {
            string str = @"that's my random string.";

            var words = new List<string>();

            Regex r = new Regex(@"\w+", RegexOptions.Compiled);
            foreach (Match word in r.Matches(str)) words.Add(word.Value);
            words.Sort();
            Console.WriteLine("Words ordered in alphabetical order: \r\n");
            foreach (string word in words) Console.WriteLine(word);
        }
    }
}
